# - Find the native FPTK includes and library

#  FPTK_INCLUDE_DIR, where to find include files
#  FPTK_LIBRARIES, list of FPTK libraries
#  FPTK_FOUND, Don't use FPTK if false.
# The following settings should not be used in general.


# If FPTK_INCLUDE_DIR is already defined we assigne its value to FPTK_DIR
IF(FPTK_INCLUDE_DIR)
  SET(FPTK_DIR ${FPTK_INCLUDE_DIR})
ENDIF(FPTK_INCLUDE_DIR)


# If FPTK has been built using CMake we try to find everything directly
SET(FPTK_DIR_STRING "directory containing FPTKConfig.cmake.  This is either the root of the build tree, or PREFIX/lib/FPTK for an installation.")

# Search only if the location is not already known.
IF(NOT FPTK_DIR)
  # Get the system search path as a list.
  IF(UNIX)
    STRING(REGEX MATCHALL "[^:]+" FPTK_DIR_SEARCH1 "$ENV{PATH}")
  ELSE(UNIX)
    STRING(REGEX REPLACE "\\\\" "/" FPTK_DIR_SEARCH1 "$ENV{PATH}")
  ENDIF(UNIX)
  STRING(REGEX REPLACE "/;" ";" FPTK_DIR_SEARCH2 ${FPTK_DIR_SEARCH1})

  # Construct a set of paths relative to the system search path.
  SET(FPTK_DIR_SEARCH "")
  FOREACH(dir ${FPTK_DIR_SEARCH2})
    SET(FPTK_DIR_SEARCH ${FPTK_DIR_SEARCH} "${dir}/../lib/FPTK")
  ENDFOREACH(dir)

  #
  # Look for an installation or build tree.
  #
  FIND_PATH(FPTK_DIR FPTKConfig.cmake
    # Look for an environment variable FPTK_DIR.
    $ENV{FPTK_DIR}

    # Look in places relative to the system executable search path.
    ${FPTK_DIR_SEARCH}

    # Look in standard UNIX install locations.
    /usr/local/lib/FPTK
    /usr/lib/FPTK
    /usr/local/include
    /usr/include
    /usr/local/FPTK
    /usr/X11R6/include

    # Read from the CMakeSetup registry entries.  It is likely that
    # FPTK will have been recently built.
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]

    # Help the user find it if we cannot.
    DOC "The ${FPTK_DIR_STRING}"
    )
ENDIF(NOT FPTK_DIR)

# If FPTK was found, load the configuration file to get the rest of the
# settings.
IF(FPTK_DIR)

  # Check if FPTK was built using CMake
  IF(EXISTS ${FPTK_DIR}/FPTKConfig.cmake)
    SET(FPTK_BUILT_WITH_CMAKE 1)
  ENDIF(EXISTS ${FPTK_DIR}/FPTKConfig.cmake)
    INCLUDE(${FPTK_DIR}/FPTKConfig.cmake)
    SET(FPTK_FOUND 1)
ELSE(FPTK_DIR)
  SET(FPTK_FOUND 0)
ENDIF(FPTK_DIR)




